package com.example.demo.controller;

import com.example.demo.entity.ResponseResult;
import com.example.demo.entity.Stock;
import com.example.demo.service.StockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.websocket.server.PathParam;

@RestController
@RequestMapping("/stock")
@Api(tags = "库存接口")
public class StockController {

    @Resource
    private StockService stockService;


    @GetMapping
    @ApiOperation(value = "查询全部库存信息")
    public ResponseResult getList(){
        return stockService.getList();
    }

    @PostMapping
    @ApiOperation(value = "保存库存信息")
    public ResponseResult saveStock(@RequestBody Stock stock){
        return stockService.saveStock(stock);
    }

    @PutMapping
    @ApiOperation(value = "更新库存信息")
    public ResponseResult updateStock(@RequestBody Stock stock){
        return stockService.updateStock(stock);
    }

    @DeleteMapping("/deleteById")
    @ApiOperation(value = "根据id删除库存信息")
    public ResponseResult deleteById(@RequestParam String id){
        return stockService.deleteById(id);
    }
}
